<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>诗词</title>
    <script src="./jquery-1.12.4.min.js"></script>
</head>
<body>
    <div class="poetry">
        <h2 class="title">王仙坛</h2>
        <h3 class="author">林杰</h3>
        <div class="content">羽客已登仙路去，丹\uD872\uDF3B草木尽凋零</div>
        <button class="next">下一首</button>
    </div>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.open('GET','http://api.apiopen.top/recommendPoetry');
        xhr.send('age=19');
        xhr.onreadystatechange = function (){
            //访问状态是数据传输完成
            if(xhr.readyState == XMLHttpRequest.DONE){
                console.log(xhr.responseText);
                var obj = JSON.parse(xhr.responseText);
                $('.title').html(obj.result.title);
                $('.author').html(obj.result.authors);
                $('.content').html(obj.result.content.replace(/\|/gi,"<br/>")); 
        }
    }
    </script>
</body>
</html>